package cn.com.config;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

public class AppRoutingDataSource extends AbstractRoutingDataSource {

    @Override
    protected Object determineCurrentLookupKey() {
        return AppDataSourceContext.getApp() ? "master" :
                UserDataSourceContext.getUserId() == null ? "master" : "user";
    }
}
